//
//  SoundManager.m
//  StarBugs
//
//  Created by ?? ? on 6/14/12.
//  Copyright 2012 antisword@playorca.com. All rights reserved.
//

#include "Util/SoundManager.h"
#include "SimpleAudioEngine.h"

using namespace CocosDenshion;
const char* soundFileName[] = 
{
    "1.Play_Click.mp3",
    "2.Setting-Shop_Click.mp3",
    "3.ZoomOut.mp3",
    "4.ZoomIn.mp3",
    "5.Shot.mp3",
    
    "6.energy_1.mp3",
    "6.energy_2.mp3",
    "6.energy_3.mp3",
    "6.energy_4.mp3",
    "6.energy_5.mp3",
    
    "6.energy_6.mp3",
    "6.energy_7.mp3",
    "7.bubble.mp3",
    "8.Die.mp3",
    "9.Item_UFO.mp3",
    
    "10.bounce_1.mp3",
    "10.bounce_2.mp3",
    "10.bounce_3.mp3",
    "10.bounce_4.mp3",
    "11.Portal.mp3",
    
    "12.Door.mp3",
    "13.Ice_Block.mp3",
    "14.UFO_Moving.mp3",
    "15.Warp.mp3",
    "16.Clear.mp3",
    
    "17.Ride_Bumpy.mp3",
    "18.Load_Click.mp3",
    "19.Item_Magnet.mp3",
    "20.Score_Star_1.mp3",
    "20.Score_Star_2.mp3",
    
    "20.Score_Star_3.mp3",
    "21.StageMark.mp3",
    "22.UFO_FallBumpy.mp3",
    "23.Water_cage.mp3",
    "24.StageClear.mp3",
    
    "Slide.mp3",
    "Battery_Out_Movie.mp3",
    "Eplosion_Movie.mp3",
    "Fall_Movie.mp3",
    "Space_Ship_Movie.mp3",
    
    "Suprise_Movie.mp3",
    "UFO_BGM1_Mixout.mp3",
    "UFO_BGM2_Mixout.mp3",
};

void SoundManager::initSoundEffect()
{
    SimpleAudioEngine::sharedEngine()->setEffectsVolume(1);
    SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(1);
    for(int i = 0; i < sndEffect_intro_suprise + 1; i++)
        SimpleAudioEngine::sharedEngine()->preloadEffect(soundFileName[i]);
}

void SoundManager::PlaySoundEffect(int num)
{
    if(SimpleAudioEngine::sharedEngine()->getEffectsVolume() != 0)
        SimpleAudioEngine::sharedEngine()->playEffect(soundFileName[num]);
}

void SoundManager::muteSoundEffect(bool flg)
{
    SimpleAudioEngine::sharedEngine()->setEffectsVolume(flg);
}


void SoundManager::PlaySoundBgm(int num)
{
    if(SimpleAudioEngine::sharedEngine()->getEffectsVolume() != 0)
        SimpleAudioEngine::sharedEngine()->playBackgroundMusic(soundFileName[num], true);
}

void SoundManager::pauseSoundBgm()
{
    if(SimpleAudioEngine::sharedEngine()->getBackgroundMusicVolume() != 0)
        SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}

void SoundManager::resumeSoundBgm()
{
    if(SimpleAudioEngine::sharedEngine()->getBackgroundMusicVolume() != 0)
        SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();    
}

void SoundManager::stopSoundBgm()
{
    if(SimpleAudioEngine::sharedEngine()->getBackgroundMusicVolume() != 0)
        SimpleAudioEngine::sharedEngine()->stopBackgroundMusic();
}

void SoundManager::muteSoundBgm(bool flg)
{
    stopSoundBgm();
    SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(flg);
}
